#include <iostream>

using namespace std;

//二分法求幂，考虑n<0

double Pow(int x, int n)
{
    double result = 1;
    int y = 0;
    int base = x;
    if(n == 0)
        return 1;
    else if(n < 0)
        y = -n;
    else
        y = n;
    
    while (y != 0)
    {
        //y是奇数base*result
        if(y % 2 == 1)
            result *= base;
        base *= base;
        y = y/2;
    }
    if(n > 0)
        return result;
    else
        return 1.0/result;    
}

int main(int argc, char const *argv[])
{
    double r = Pow(4,-1);
    cout << r;
    return 0;
}
